

package com.hazelcast.internal.services;

import com.hazelcast.spi.impl.NodeEngine;

import java.util.Properties;

/**
 * An interface that can be implemented by an SPI Service to receive lifecycle calls:
 * <ol>
 * <li>initialization</li>
 * <li>shutdown</li>
 * <li>reset</li>
 * </ol>
 */
public interface ManagedService {

    /**
     * Initializes this service.
     *
     * @param nodeEngine the NodeEngine that this service belongs to
     * @param properties the Properties (can be used to pass settings to the service)
     */
    void init(NodeEngine nodeEngine, Properties properties);

    /**
     * Resets this service back to its initial state. This should represent the same
     * state that the service would be in after a normal startup, including config
     * defined properties being loaded.
     * <p>
     * Some of the uses for the #reset() method include usage in "force start" scenarios
     * with Hot Restart, and during split-brain merging.
     */
    void reset();

    /**
     * Shuts down this service.
     * <p>
     * TODO: what is the purpose of the terminate variable
     *
     * @param terminate {@code true} to shut down this service
     */
    void shutdown(boolean terminate);
}
